home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-21
/
dvcron21.zip
/
CRON.DOC
< prev
next >
Wrap
Text File
|
1992-01-19
|
8KB
|
200 lines
Cron 2.0
(c) 1991 -- Kyle A. York
------------------------
Here's my attempt to port the Unix Cron utility to MS-DOS. Feel free
to do with program as you please --but-- always leave my name in the
source and documentation and ALWAYS note any changes you have made. I
don't want bad code running around with my name on it.
please read WHATSNEW
Acknowledgements
================
Ralph Brown for his invaluable interrupt list and DVGLUE library.
Command Format
==============
CRON [-c filename] [-d filename] [-l filename] [-l-] [-m memsize]
-d filename : set the template .dvp file to filename
-c filename : set the CRONTAB file to filename (default is crontab
in the same directory as cron.exe)
-l filename : set global logfile to filename (default is cron.log
in the same directory as cron.exe)
-l- : disable the global log file
-m memsize : set the CRONTAB buffer to memsize. default is 1K.
CRONTAB format
==============
the first 5 fields are: minute (0-59), hour (0-23), day of month (1-
31), month of year (1-12) and day of week (0-6, 0=sunday). A '*' is
used for "any allowable value". The fields are seperated by spaces.
ex: 0 0 1,15 * 3 [switches] {command} [paramaters]; ...
will execute the command at 00:00 on the 1st and 15th of every month
and on every Wednesday. The number list can be comma-seperated
(1,15) or ranges (1-5,6-9). VERY LITTLE error checking is done. If a
number is out of range, it will never be found so {command} will
never be executed. If a * appears anywhere in the field, the fields
will ALWAYS match (eg 1,2,4-7,*,9 is equivalent to *). A range is
assumed to be low to high. If it is entered high to low, only the
limits will match (eg 7-4 will match 7 and 4, but not 5 and 6
whereas 4-7 will match 4,5,6,7).
{command} format
This is where I had to deviate somewhat from the UNIX format. The
command can be optionally preceded by some switches as follows:
-b : force this window to start in the background
-c n : if n < 0, set minimum conventional memory to -n K
: if n > 0, set maximum conventional memory to n K
: this might seem kind of clunky but its the best I could
: think to do.
-e n : set maximum expanded memory to n K
-h : force this window to start hidden
-l name : set local log file to name
if name = "-", reset to normal global log file
The local log file remains in effect for the line or until the "-l-"
switch is entered. If the command has the extension '.exe',
'.com', or '.dvp' it must also have the full path to reach the
file. In other words the DOS path is not traversed to find the
program. Any other extension (most notably ".bat") will load the
current command shell (normally COMMAND.COM) and pass the command
as a parameter.
If the command has an extension '.exe' or '.com' the window is set
to close on completion. If it has a '.dvp' then the command is run
verbatim from the info in the '.dvp'. If it has any other
extension, the command interpreter is loaded and the command is
sent to the interpreter. Generally if you are running a batch file
and you want the window to close on completion, the last command
in the batch file should be 'exit'.
parameters format
The parameters string is parsed for the following strings:
%M, %D, %Y, %h, %m
If these are found, %M is replaces with the 2-digit month, %D with
the 2-digit day of month, %Y with the 2-digit year %h with the 2-
digit hour, and %m with the 2-digit minute. An example of this is
included in the example CRONTAB file. I needed a way to backup my
disks using a unique name, and the month + day strings worked
quite well.
After this parsing, the parameters are sent to the program.
commands may be "stacked" on a line
eg:
5 6 * * * cmd1; cmd2; cmd3
will execute command1, command 2, and command 3 at 06:05a. any
switches will remain in effect until either changed or the line ends
eg:
5 6 * * * -c20 cmd1; cmd2; -c80 cmd3
5 6 * * * cmd4
This will run cmd1 and cmd2 with 20K of conventional memory, and
cmd3 with 80K. cmd4 will get the default. since there is no undoing
"-b" (background) and "-h" (hide) these switches will remain in
effect until the end of the line and will be reset for the next
line.
eg:
5 6 * * * -b cmd1; cmd2
5 6 * * * cmd3
This will run cmd1 and cmd2 in the background, and cmd3 in the
default setting.
Multiple commands on a line are started as multiple concurrent
processes. In other words in the above example, cron DOES NOT wait
for the completion of cmd1 before starting cmd2 and cmd3 so BE
CAREFUL not to run short on memory if you start multiple processes
simultaneously.
If you need to send a ';' to your shell, simply use ';;'.
eg:
5 6 * * * cmd parm1 ;; parm2 ;; parm3
Will run cmd using parameters "parm1 ; parm2 ; parm3"
Limitations
DESQview allows only 63 characters for the full path to the program,
and 63 characters for the parameters. If the parameters string is
greater than 63 characters it is truncated with a warning written to
the log file. If a '.bat' file is run, the path to the program is
cleared and the parameters are set to the program name + parameters
therefore the full string (program name + parameters) must be less
than 63 characters. If not it is truncated with a warning written to
the log file.
Also, opening a new application is done using DVapp_start(). From
the DVGLUE documentation:
"This function is known to cause lockups under DV 2.00 (6-16-87).
Use at your own risk (though I would appreciate hearing from you
which version (and date) you are using and whether or not it
worked). [Ralph Brown]"
I have used this with DV 2.4 without problems, your mileage may
vary.
When DESQview tries to open a new process and there is not enough
memory, it will write another process to disk (aka swapping).
Unfortunatly if memory later thins out, it will NOT automatically
retrieve a swapped process so be careful when starting numerous
commands.
Comments
The CRONTAB file is opened when CRON begins and is left open while
CRON is running. Therefore it is HIGHLY RECOMMENDED that you also
load SHARE.EXE so one doesn't accidently deleted the file as this
would have highly unpredictable results. I use the timer functions
of DV so the amount of time spent in CRON is minimal. With a 3 line
CRONTAB file which executes commands once per day, and some once per
hour, my machine uses only about 1 minute / day for the CRON
process. Each minute, the first thing done is a check on CRONTAB to
see whether it's been modified. If it has, it is re-read. You will
note that there is no year entry in the CRONTAB file. This means
that a CRONTAB entry will never expire. If you set it to a certain
date (say 12 December) then it will execute only once per year.
I have been using this program for about one week and have tried
every parameter but I cannot guarentee this will not crash. If it
does, or you have any other problems, please mail me at
Internet:
noesis@ucscb.ucsc.edu
kyley@cats.ucsc.edu
CompuServe:
72125,1533
Technical Stuff
This program was compiled with Turbo C 2.0 using the small memory
model and optimization set to 'size'. I've heard it said "never set
optimization to size" and always believed it until now. I felt there
was little speed gain to be had.
I tried my best to keep this thing small, and am very happy with the
21K result. If you see somewhere that the code can be optimized
please let me know.
Registration
If you use this program, please register it by mailing me at any
address above. If you would, include a brief description of your
setup and why you use cron. This is for my info only, if you do not
want to give me a description, that's fine but <<PLEASE>> let me
know who you are!